<?php
	//Xay dung tim kiem
	$ssFilter 		= $this->arrParam['ssFilter'];
	$type_menu = '';
	if(isset($this->arrParam['type_menu'])){
		$type_menu = '/type_menu/' . $this->arrParam['type_menu'];
	}
	$action_link 	= $this->baseUrl($this->currentController . '/filter/type/order' . $type_menu);
	
	$keywords = $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort'));
	
	$linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/1' . $type_menu);
	$btnSerach = $this->formButton('search-now','Tìm',array('onclick'=>"OnSubmitForm('" .$linkSearch . "')"));
	
	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0' . $type_menu);
	$btnResetSerach = $this->formButton('clear-keywords','Xóa',array('onclick'=>"OnSubmitForm('" .$linkResetSearch ."')"));
	
	$selectLanguages = $this->slbLanguages;
	$linkSlbLanguages = $this->baseUrl($this->currentController . '/filter/type/lang');
	$selectLanguages = $this->formSelect('lang_code',$ssFilter['lang_code'],array('onchange'=>"OnSubmitForm('" .$linkSlbLanguages ."')"),$selectLanguages);
	
	$linkMenu = $this->baseUrl($this->currentController . '/filter/type/category' . $type_menu);
	$selectMenu = $this->cmsSelect('parents',$ssFilter['parents'],$this->slbMenu,array('style'=>'min-width:200px;','onchange'=>"OnSubmitForm('" .$linkMenu ."')"));
	
	$strSearch = $keywords . ' ' . $btnSerach . ' ' . $btnResetSerach;
	$strSearchRight = $selectMenu . ' ' . $selectLanguages;
?>
<form name="appForm" method="post" action="">
	<?php echo $this->render('admin-menu/toolbar/index.php');?>
 	<div class="clr"></div>
	<?php echo $this->render('admin-menu/sublink/index.php');?>	

	<!-- BEGIN: CONTENT -->
	<div class="app_content goc10">
		<div class="block_filter">
			<div class="fl">
				<?php echo $strSearch;?>
			</div>
			<div class="fr">
				<?php echo $strSearchRight;?>
			</div>
			<div class="clr"></div>
		</div>
		<table class="adminlist">
			<tr>
				<th width="20">#</th>
				<th width="20">
					<input type="checkbox" name="checkbox" id="checkbox" onclick="checkedAll()">
				</th>
				<th>Tên danh mục</th>
				<th width="70">Status</th>
				<th width="70">Parents</th>
				<th width="100">Order</th>
				<th width="120">Tạo bởi</th>
				<th width="120">Kiểu</th>
				<th width="90">Control</th>
				<th width="70">Ngôn ngữ</th>
				<th width="34">ID</th>
			</tr>
			<?php
			if(count($this->Items)>0){	
				foreach ($this->Items as $key => $val){
					$id 			= $val['id'];
					$name 			= $val['name'];
					$parents 		= $val['parents'];
					$user_name 		= $val['user_name'];
					$order 			= $this->formText('order[' . $val['id'] . ']', $val['order'], array('style'=>'width: 30px; text-align: center;'));
					$lang_code		= $val['lang_code'];
					$module_options	= $val['module_options'];
					
					$status 		= $val['status'];
					if($status == 1){
						$linkStatus = $this->baseUrl($this->currentController . '/status/type/0/id/' . $id . $type_menu);
						$status = $this->cmsIconButton('Kích vào để tắt', $this->imgUrl . '/admin/tick.png', $linkStatus);
					}else{
						$linkStatus = $this->baseUrl($this->currentController . '/status/type/1/id/' . $id . $type_menu);
						$status = $this->cmsIconButton('Kích vào để bật', $this->imgUrl . '/admin/publish_x.png', $linkStatus);
					}
					$linkInfo		= $this->baseUrl($this->currentController . '/info/id/' . $id . $type_menu);
					$btnInfo		= $this->cmsIconButton('Xem thông tin', $this->imgUrl . '/admin/icon_info.png', $linkInfo);
					
					$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id . $type_menu);
					$btnEdit		= $this->cmsIconButton('Sửa', $this->imgUrl . '/admin/icon_edit.png', $linkEdit);
					
					$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id . $type_menu);
					$btnDelete		= $this->cmsIconButton('Xóa', $this->imgUrl . '/admin/publish_r.png', $linkDelete);
					
					$strIconButton 	= $btnEdit . ' ' . $btnDelete;
					
					$name 	= '<a href="' . $linkEdit . '">' . $name . '</a>';
					//$alias 	= 'khong-co-gi-la-khong-the';
					if($val['level'] == 1){
						$name = '<strong>' . $name . '</strong>';
						$alias = '(Alias: ' . $alias . ')';
					}else{
						$string = '<span class="gi">|—</span>';
						$strAlias = '<span class="gtr">|—</span>';
						$newString = '';
						$newAlias = '';
						for($i=1;$i<$val['level'];$i++){
							$newString 	.= $string;
							$newAlias	.= $strAlias;
						}
						$name = $newString . $name;
						$alias = $newAlias . '(Alias: ' . $alias . ')';
					}
					//$alias = '<p class="smallsub">' . $alias . '</p>';
					$alias = '';
					
					$cid 			= $this->formCheckbox('cid[]',$val['id']);
					
					$classRow = 'row1';
					if($key % 2 == 0)
						$classRow = 'row0';
					
			?>
			<tr class="<?php echo $classRow;?>">
				<td align="center"><?php echo $key + 1;?></td>
				<td align="center"><?php echo $cid;?></td>
				<td align="left"><?php echo $name . $alias;?></td>
				<td align="center"><?php echo $status;?></td>
				<td align="center"><?php echo $parents;?></td>
				<td align="center"><?php echo $order;?></td>
				<td align="center"><?php echo $user_name;?></td>
				<td align="center"><?php echo $module_options;?></td>
				<td align="center"><?php echo $strIconButton;?></td>
				<td align="center"><?php echo $lang_code;?></td>
				<td align="center"><?php echo $id;?></td>
			</tr>
			<?php
				}
			}
			?>
			<tr class="tbl_footer">
				<td colspan="12">
					<div class="container">
						<div class="pagination">
							<?php
								//$currentUrl = $this->baseUrl($this->currentController . '/index');
								//echo $this->paginationControl($this->paginator,'Sliding','pagination.phtml',array('currentUrl'=>$currentUrl)); 
							?>
						</div>
					</div>
				</td>
			</tr>
		</table>
		<div class="clr"></div>
	</div>
	<!-- END: 	CONTENT -->
</form>